

layui.use(['laydate','form'], function(){
    var laydate = layui.laydate;
    var form = layui.form;
    //执行一个laydate实例
    laydate.render({
        elem: '#test1' //指定元素
        ,type: 'datetime'
    });
    //监听提交，发送请求
    form.on('submit(add)', function(data){

        $.post("add",data.field,function(data){
            // 获取 session
            if(data.status!=200){
                layer.alert(data.message, {offset: 't',icon: 2});
            }
            if(data.status==200){
                layer.alert(data.message, {offset: 't',icon: 1},function (index) {
                    layer.close(index);
                    var index2 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index2);
                });
            }
        });
        return false;
    });
});
